package uwosh.cs342.project1;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

public class AddGroupActivity extends Activity {
	EditText returnText;

	@Override
	public void onCreate (Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.addgroup_layout);
	}//end onCreate
	
	/*	The confirmAddGroup method is called when the confirmAddGroup button is pressed.
	 * 	Here the string entered in the group name text box is taken and then passed back
	 * 	to the main activity using an Intent object.
	 * 	
	 * 	The result code I used is a 4 digit ID starting with 6, to prevent any confusion
	 * 	with existing result code constants.	*/
	public void confirmAddGroup(View view){
		Intent myIntent = new Intent();
		returnText = (EditText)this.findViewById(R.id.textGroupName);
		
		//If there is no text entered for the group name, prevent group creation
		if(returnText.length() < 1){
			//Enter code for a popup/dialog box
		}
		else{
			myIntent.putExtra("uwosh.cs342.project1.groupName", returnText.getText().toString());
			setResult(6000, myIntent);
			finish();
		}
	}//end confirmAddGroup
	
	/*	This method is called when the Cancel button is pressed. It finishes the current
	 * 	activity without passing back any information.	*/
	public void cancelAddGroup(View view){
		finish();
	}//end cancelAddGroup
}//end class
